Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update/list view outline information about post #50414

Open
wants to merge 16 commits into
base: trunk
Choose a base branch
from

Conversation

n2erjo00
Copy link
Contributor

@n2erjo00 n2erjo00 commented May 6, 2023

What?

In the editors list view outline section added "Headings", "Paragraphs" and "Blocks" fields, which show total amount of mentioned element in the post.

Created new tab "Info" to house requested fields.

Also HTML structure changed from divs and spans to ul to improve HTML quality and accessibility

Why?

Issue was brought up in here #50280

How?

Added code which calculates the total values of the elements.
Changed structure of HTML to split content between two columns.

Testing Instructions

  1. Open existing post (or page)
  2. Open List view and then open Outline tab
  3. Input new blocks, new paragraphs and headings
  4. Open new post (don't save it)
  5. Open List view and open Outline tab
  6. Input new blocks, new paragraphs and headings

Testing Instructions for Keyboard

Screenshots or screencast

Screenshot 2023-07-26 at 15 50 16

@gziolo gziolo added [Type] Enhancement A suggestion for improvement. [Feature] Document Outline An option that outlines content based on a title and headings used in the post/page labels May 7, 2023
Copy link
Contributor

@alexstine alexstine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@n2erjo00 Thanks for the PR. I think this is a nice chance to make this section more accessible to screen reader users. Instead of using a visual 2 columns, let's use a table here instead? Visual columns are just that, visual columns.

@n2erjo00
Copy link
Contributor Author

@alexstine Good catch. One table coming up. I'll whip it up today at the evening

@n2erjo00 n2erjo00 requested a review from alexstine May 22, 2023 19:27
Copy link
Contributor

@alexstine alexstine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@n2erjo00 Code looking good. One suggestion below.

@WordPress/gutenberg-design Might want to give this one a visual review for me?

</caption>
<thead className="screen-reader-text">
<tr>
<th scope="col">{ __( 'Metric' ) }</th>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are duplicated. Only need 2, not 4.

@alexstine alexstine added the [Package] Edit Post /packages/edit-post label May 22, 2023
@alexstine alexstine requested review from Mamaduka and a team May 22, 2023 20:01
return {
headingCount: getGlobalBlockCount( 'core/heading' ),
paragraphCount: getGlobalBlockCount( 'core/paragraph' ),
blockCount: blocks.length ? blocks.length : 0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TableOfContentsPanel panel uses getGlobalBlockCount here as well.

const { headingCount, paragraphCount, numberOfBlocks } = useSelect(
( select ) => {
const { getGlobalBlockCount } = select( blockEditorStore );
return {
headingCount: getGlobalBlockCount( 'core/heading' ),
paragraphCount: getGlobalBlockCount( 'core/paragraph' ),
numberOfBlocks: getGlobalBlockCount(),
};
},
[]
);

@Mamaduka
Copy link
Member

I left a small note, but from a code perspective, this looks good.

This implementation uses tables instead of a list like the old TableOfContentsPanel component.

@afercia, you reviewed the original content structure PR. Was there a reason for choosing the list markup over tables?

@afercia
Copy link
Contributor

afercia commented Jul 11, 2023

Sorry I'm late to the party. I'd totally agree to add back the information about "Headings", "Paragraphs" and "Blocks" and I'd support this PR's effort, thank you! I don't see any good reason to remove important information.

@Mamaduka @alexstine regarding the table, I'm not sure this data can be represented correctly with a table. Well, it could be, but the table should have two columns: metrics and value. The table in this PR has 4 columns: metrics and value and again metrics and value. Actually, the 4 columns are used for visual purposes. Repeating metrics and value twice doesn't seem ideal to me.

For clarity, I copied and pasted the HTML output from this PR in a codepen at https://codepen.io/afercia/full/PoxOMLZ so that it can be tested more easily. Screenshot:

Screenshot 2023-07-11 at 10 26 20

Aside:
The caption text Outline information about current post doesn't seem ideal to me:

  • This is not an outline.
  • We should not specify 'current post'.
  • In the previous implementation, this info was wrapped within a role="note" with an aria-label="Document Statistics". Maybe the role was a bit pointless but I'd use the Document Statistics terminology somewhere.

Overall, I'm not sure. a table is appropriate in this case. I'd just use a list. Worth mentioning the current HTML on trunk is just a bunch of divs and spans, which is totally unsemantic and, honestly, a poor document structure. A regression in semantics quality compared to WP 6.1.

Lastly, I'm not sure the info about Characters / Words / Time to read / Headings / Paragraphs / Blocks should live in the 'Outline' tab. This tab should only contain the Document outline. I'd consider a third tab dedicated to the statistics.

@alexstine
Copy link
Contributor

@afercia Nice catch. I totally missed that. I just got really annoyed with how this info was being displayed so thought a table could make sense. At least the table could give us data relationships vs. a bunch of divs/spans for a fake list.

@afercia
Copy link
Contributor

afercia commented Jul 18, 2023

@alexstine thanks. When you have a chance, what about this point?

Lastly, I'm not sure the info about Characters / Words / Time to read / Headings / Paragraphs / Blocks should live in the 'Outline' tab. This tab should only contain the Document outline. I'd consider a third tab dedicated to the statistics.

I would like to make the 'Outline' tab contain only the document outline, in the first place.

@alexstine
Copy link
Contributor

@afercia That's probably a fair point to make, just not sure what we would put in the Outline tab since List View tab is probably closer to an outline users would expect.

@n2erjo00
Copy link
Contributor Author

@afercia @alexstine Is the consensus that what we need is

  1. Tab called "Info"
  2. Data which was requested in the ticket should live in there in the form of <ul>
  3. Current data which is printed in the "Outline" tab should be refactored into <ul>

@afercia
Copy link
Contributor

afercia commented Jul 24, 2023

@n2erjo00 thanks for the ping.
The new tab name Info or Statistics sounds good to me.
Not sure there's agreement about the other two points. I'd defer to @alexstine
To me, the simpler, the better.

@alexstine
Copy link
Contributor

Sounds fine to me, as long as it is a proper <ul>.

@alexstine alexstine added the [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). label Jul 24, 2023
@n2erjo00 n2erjo00 requested a review from alexstine August 4, 2023 16:09
@n2erjo00
Copy link
Contributor Author

@alexstine Gentle nudge

@alexstine
Copy link
Contributor

@n2erjo00 Sorry about this. I guess I forgot about this PR with WordCamp US happening. Can you give this a refresh from latest trunk? Packages have changed and my NPM is too new to build this now.

Thanks.

@n2erjo00
Copy link
Contributor Author

@alexstine No worries even I had completely forgot the existence of this 😅 Latest trunk merged to this branch

Copy link
Contributor

@alexstine alexstine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@n2erjo00 This is testing well. A couple fixes:

  1. There is no space after the ":" so screen readers read out as "Characters:10" vs. "Characters: 10". Does not sound like a large issue until you listen to it for yourself. Is there a way you can add spacing, maybe outside of the translations? I'm not sure it is a good practice to include whitespace in translations but might be wrong about that.
  2. The useInstanceId hook takes a second parameter, prefix. You could simplify the code. I left a comment with specific examples. Be sure to apply it to both files.

<div>
<div className="edit-post-editor__list-view-overview__container">
<p
id={ `edit-post-editor-list-view-overview-outline-${ instanceId }` }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
id={ `edit-post-editor-list-view-overview-outline-${ instanceId }` }
id={ instanceId }

@@ -63,24 +64,37 @@ export default function ListViewOutline() {
headingCount: getGlobalBlockCount( 'core/heading' ),
};
}, [] );
const instanceId = useInstanceId( ListViewOutline );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const instanceId = useInstanceId( ListViewOutline );
const instanceId = useInstanceId( ListViewOutline, 'edit-post-editor-list-view-overview-outline' );

Copy link
Contributor

@alexstine alexstine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@n2erjo00 Thanks for all the hard work here. This is testing well for me.

Tagging @andrewserong for final review.

@alexstine alexstine removed the [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). label Sep 27, 2023
@andrewserong
Copy link
Contributor

Thanks for the ping, and for the work here @n2erjo00!

Adding a new tab is a fairly prominent change, and I think it's a great idea listing out more stats about the number of different blocks within the document, whether that's included in the existing Outline tab, or in a new Info tab.

From playing around with the change, it looks like it could use a pass from a designer to ensure that the text is visually consistent with other areas of the app (e.g. spacing between the text and edge of the window, sizing, colours, etc), so I'll just add the Needs Design Feedback label to this PR.

Here's how the Outline and Info tabs are looking for me currently in testing:

Outline tab Info tab
image image

Nice work so far!

@andrewserong andrewserong added the Needs Design Feedback Needs general design feedback. label Sep 27, 2023
@jameskoster
Copy link
Contributor

I don't know if there's enough 'information' to warrant an entire tab. Could that data live in the Outline tab? Here's a quick mockup:

outline

Alternatively could all the data points live in the Info tab, leaving the Outline tab to concentrate solely on the outline?

info

@n2erjo00
Copy link
Contributor Author

@jameskoster Sure they could live in same tab 😄 Looking back at the discussions on this PR simpler the better was the reason to split between Outline and Info.

Based on the mockups I'd go with Outline and Info split. Since Outline already contains the heading structure (and it can eat a lot of space) putting black-and-white statics at the end would make Outline too crowded and little taxing to find them (if lot of headings).

I think I have time on upcoming weekend whip up the following

  1. Remove following fields from the current "Outline" tab (Characters, Words, Time to read)
  2. Add following fields to "Info" tab (Character, Words, Time to read)
  3. Whip up some styles so the end result resembles closely to the mockups

@n2erjo00
Copy link
Contributor Author

@jameskoster Did the things, honest but brutal feedback appreciated 😄

PS Mocks contained changes to "Multiple H1..." warning box. I did not implement these changes since they are not what this PR is for.
PSS Warning box design is much better than what we currently have 😄 I would love to see it some day in the trunk

Copy link
Contributor

@andrewserong andrewserong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for continuing on with this @n2erjo00! Code-wise it's looking pretty good to me.

In re-testing with some shorter blog-post-like content, I think it's pretty common to have posts that don't have very many headings, and in these cases, it means the Outline tab can be fairly empty. In playing around with this in my test environment, I think my personal preference would be to keep the Information as a footer section within the Outline tab as in James' mockup #50414 (comment). Having a separate tab for Info feels to me like it'd be more useful for posts that have very complex heading hierarchies, which I suspect are in the minority. And the footer idea for the Info section sounds like it could be a good way to mitigate that situation, too.

Here's a couple of screenshots of how it's looking for me:

Outline tab in a short post Info tab in a short post
image image

@jameskoster
Copy link
Contributor

Mocks contained changes to "Multiple H1..." warning box. I did not implement these changes since they are not what this PR is for.

That's fine :)

Having a separate tab for Info feels to me like it'd be more useful for posts that have very complex heading hierarchies, which I suspect are in the minority

I tend to agree, the outline tab is often sparse, and the info tab isn't exactly dense. It would be nice to keep them combined.

I would like to make the 'Outline' tab contain only the document outline, in the first place.

Perhaps @afercia could elaborate on why the separate tabs are preferred. Is there an alternative such as labelling the tab "Outline & info", or even just "Info" if a case can be made that the outline is informational?

information

@n2erjo00
Copy link
Contributor Author

n2erjo00 commented Nov 6, 2023

@afercia Gentle nudge. See comment above ☝️

@n2erjo00
Copy link
Contributor Author

@afercia Gentle nudgy-nudge-nudge

Copy link

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: n2erjo00 <n2erjo00@git.wordpress.org>
Co-authored-by: alexstine <alexstine@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
Co-authored-by: afercia <afercia@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Document Outline An option that outlines content based on a title and headings used in the post/page Needs Design Feedback Needs general design feedback. [Package] Edit Post /packages/edit-post [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants